var top_switchdelay=7000; //delay between msg scrolls. 3000=3 seconds.
var top_images=new Array()

//image, title, text, link
//images must be in the /images/features folder in teamsite

top_images[top_images.length]=['cancer-doesnt-care.jpg','free medication and other help.','Care enough to quit smoking today','http://www.nyc.gov/cgi-bin/exit.pl?url=https://www.nysmokefree.com/register/default.aspx?no=nycdoh'];
top_images[top_images.length]=['nycbeach-txting.jpg','New York City area beaches','A free texting service so you can \"Know Before You Go\" if your beach is open, and receive alerts about advisories, closures or water quality issues.','../../html/environmental/beach.shtml'];
top_images[top_images.length]=['apps-module.jpg',' and download the NYC Health smartphone apps','NYC Health smartphone applications (\"apps\") help connect New Yorkers to vital services and information from their mobile devices at no cost.','../../html/media/apps.shtml'];
top_images[top_images.length]=['home_ny_dog_license.jpg','Dog Licenses','By law, all dogs owned in New York must be licensed and have a license tag attached to their collar while in public.','../../html/licenses/vet-doglicense.shtml'];
//top_images[top_images.length]=['home_restaurant_inspection_grade.jpg','Restaurant Inspections','Did your favorite diner make the grade? All restaurants are graded according to how well they comply with the food safety requirements of NYC Health.','../../html/services/restaurant-inspection.shtml'];
//top_images[top_images.length]=['home_baby_birth_certificate.jpg','Birth Certificates','There are three ways to get a certified copy of your birth certificate: mail, online or in-person.','../../html/services/vr.shtml'];

//top_images[top_images.length]=['measlesvirus.jpg','measles','More cases diagnosed in the city.','../../html/diseases/immmea.shtml'];

//top_images[top_images.length]=['Marie-banner.jpg','quitting smoking','Quitting smoking is the single most important thing you can do for your health. Quit smoking today.','https://a816-nycquits.nyc.gov/pages/homepage.aspx'];

//top_images[top_images.length]=['project-hope.jpg','Project HOPE','If you feel overwhelmed after Hurricane Sandy, please call 1-800-LIFENET to connect with Project HOPE','../../html/em/project-hope.shtml'];
//top_images[top_images.length]=['stay-safe-in-the-cold.jpg','cold weather safety ','Living without heat or being outdoors in the cold weather for prolonged times can be dangerous. Protect yourself and help others who may be at increased risk of health problems from the cold.','../../html/environmental/cold-weather-safety.shtml'];





var top_switch_running = false;
var top_switch_stopped = false;
var blendDone=true;
var top_switch_i=0;
var top_timeout;
var imgWidth=779;
var imgHeight=345;

function top_switchImage(){
	if(!top_switch_stopped){
		if(!blendDone){
			top_timeout=setTimeout("top_switchImage()",10);
		}else{
			top_blendimage(top_switch_i);
			var theButtons="";
			for(var i=0;i<top_images.length;i++){
				if(theButtons.length>0){
					theButtons=theButtons+"&nbsp;&nbsp;";
				}
				if(i==top_switch_i){
					theButtons=theButtons+'<a href="javascript:top_activeImage('+i+');"><img src="../../includes/site_images/misc/button_1.png" width="13" height="13" border="0" alt="'+top_images[i][1]+'" title="'+top_images[i][1]+'"></a>';
					document.getElementById('home_top_text').innerHTML=getHomeTopText(top_switch_i);
				}else{
					theButtons=theButtons+'<a href="javascript:top_activeImage('+i+');"><img src="../../includes/site_images/misc/button_0.png" width="13" height="13" border="0" alt="'+top_images[i][1]+'" title="'+top_images[i][1]+'"></a>';
				}
			}
			document.getElementById('topics_buttons').innerHTML=theButtons;
			if(top_switch_i==top_images.length-1){
				top_switch_i=0;
			}else{
				top_switch_i++;
			}
			top_timeout=setTimeout("top_switchImage()",top_switchdelay);
		}
	}
}

function top_blendimage(theIndex) {
	blendDone=false;
    var speed = 6;
    var timer = 0;
    
    //set the current image as background
    document.getElementById('top_blenddiv').style.backgroundImage = 'url("' + document.getElementById('top_blendimage').src + '")';
    //make image transparent
    changeOpac(0, 'top_blendimage');
    
    //make new image
    document.getElementById('top_blendimage').src = "../../images/features/"+top_images[theIndex][0];
    document.getElementById('top_blendimage').alt = top_images[theIndex][1];
    //fade in image
    for(var t = 0; t <= 100; t++) {
        setTimeout("changeOpac(" + t + ",'top_blendimage')",(timer * speed));
        timer++;
        if(t==100){
	        blendDone=true;
        }
    }

}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
	opacity = (opacity == 100)?99.999:opacity;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function top_activeImage(theId){
	stop_top_switch();
	top_switch_i=theId;
	top_blendimage(top_switch_i);
	var theButtons="";
	for(var i=0;i<top_images.length;i++){
		if(theButtons.length>0){
			theButtons=theButtons+"&nbsp;&nbsp;";
		}
		if(i==top_switch_i){
			theButtons=theButtons+'<a href="javascript:top_activeImage('+i+');"><img src="../../includes/site_images/misc/button_1.png" width="13" height="13" border="0" alt="'+top_images[i][1]+'" title="'+top_images[i][1]+'"></a>';
			document.getElementById('home_top_text').innerHTML=getHomeTopText(top_switch_i);
		}else{
			theButtons=theButtons+'<a href="javascript:top_activeImage('+i+');"><img src="../../includes/site_images/misc/button_0.png" width="13" height="13" border="0" alt="'+top_images[i][1]+'" title="'+top_images[i][1]+'"></a>';
		}
	}
	document.getElementById('topics_buttons').innerHTML=theButtons;
	restart_top_switch();
}

function top_back(){
	if(top_switch_i==1){
		top_activeImage(top_images.length-1);
	}else if(top_switch_i==0){
		top_activeImage(top_images.length-2);
	}else{
		top_activeImage(top_switch_i-2);
	}
}
function top_next(){
	top_activeImage(top_switch_i);
}
function top_stop(){
	stop_top_switch();
	document.getElementById('top_feature_play').innerHTML='<a href="javascript:top_restart();"><img src="../../includes/site_images/misc/play.png" width="12" height="36" border="0" alt="Play"></a>'
}
function top_restart(){
	restart_top_switch();
	document.getElementById('top_feature_play').innerHTML='<a href="javascript:top_stop();"><img src="../../includes/site_images/misc/pause.png" width="12" height="36" border="0" alt="Pause"></a>'
}

function start_top_switch(){
	// make sure function doesn't fun twice
	if (top_switch_running)
		return
	top_switch_running=true;
	top_timeout=setTimeout("top_switchImage()",1000);
}

function stop_top_switch() {
	clearTimeout(top_timeout);
	top_switch_stopped = true;
}

function restart_top_switch() {
	if (top_switch_stopped){
		top_switch_stopped = false;
		top_timeout=setTimeout("top_switchImage()",1000);
	}
}

function getHomeTopText(theIndex){
	var theText=top_images[theIndex][2];
	if(top_images[theIndex][3].length>0){
		theText=theText+'<br><img src="../../includes/site_images/misc/feature_arrow.png" width="10" height="9" border="0" alt="" style="margin-right:5px;"><a href="'+top_images[theIndex][3]+'" class="top_feature_link">Learn more about <b>'+top_images[theIndex][1]+'</b></a>';
	}
	return(theText);
}

document.write('<div class="top_feature"><div style="position:absolute; top:0px; left:0px;background-image: url(\'../../images/features/'+top_images[0][0]+'\'); background-repeat: no-repeat; width:'+imgWidth+'px; height:'+imgHeight+'px;" id="top_blenddiv"><img src="../../images/features/'+top_images[0][0]+'" width="'+imgWidth+'" height="'+imgHeight+'" alt="'+top_images[0][1]+'" border="0" id="top_blendimage" style="filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0;"></div>');
document.write('<div class="home_top_gradient" style="position:absolute; top:0px; left:0px; z-index:5; height:'+imgHeight+'px; width:'+imgWidth+'px;"><table cellspacing="0" cellpadding="0" border="0" width="100%">');
document.write('<tr><td class="home_top_controls" id="home_top_controls"><table cellspacing="0" cellpadding="0" border="0">');
document.write('<tr><td class="top_controls_title">More topics:</td></tr>');
document.write('<tr><td class="topics_buttons" id="topics_buttons"><a href="javascript:top_activeImage(0);"><img src="../../includes/site_images/misc/button_1.png" width="13" height="13" border="0" alt="'+top_images[0][1]+'" title="'+top_images[0][1]+'"></a>');
for(var i=1;i<top_images.length;i++){
	document.write('&nbsp;&nbsp;<a href="javascript:top_activeImage('+i+');"><img src="../../includes/site_images/misc/button_0.png" width="13" height="13" border="0" alt="'+top_images[i][1]+'" title="'+top_images[i][1]+'"></a>');
}
document.write('</td></tr>');
document.write('<tr><td class="topics_controls"><table cellspacing="0" cellpadding="0" border="0">');
document.write('<tr><td id="top_feature_back"><a href="javascript:top_back();"><img src="../../includes/site_images/misc/back.png" width="9" height="35" border="0" alt="Back"></a></td>');
document.write('<td id="top_feature_play" class="top_feature_play"><a href="javascript:top_stop();"><img src="../../includes/site_images/misc/pause.png" width="12" height="35" border="0" alt="Pause"></a></td>');
document.write('<td id="top_feature_next"><a href="javascript:top_next();"><img src="../../includes/site_images/misc/next.png" width="9" height="35" border="0" alt="Next"></a></td></tr>');
document.write('</table></td></tr></table></td><td class="home_top_text" id="home_top_text">'+getHomeTopText(0)+'</td></tr>');
document.write('</table></div></div>');

addLoadEvent(start_top_switch);
//addLoadEvent(start_top_stop);